﻿using System.Collections.ObjectModel;
using Might.Infrastructure.Annotations.Graphics;
using Might.Infrastructure.ModelicaDOM;
using Might.Infrastructure.DOM;

namespace Might.Modelica.Annotations.Graphics {
    ///<summary>
    ///</summary>
    [Mapping("Diagram")]
    [AnnotationDOMGroup(GroupNames.Diagrams)]
    public class Diagram : GraphicsItem {
        ///<summary>
        ///</summary>
        public Diagram() {
            coordinateSystem = new CoordinateSystem();
            Content = new ObservableCollection<IGraphicsItem>();
        }

        ///<summary>
        ///</summary>
        ///<param name="coordinateSystem"></param>
        ///<param name="graphics"></param>
        public Diagram(CoordinateSystem coordinateSystem, ObservableCollection<IGraphicsItem> graphics) {
            this.coordinateSystem = coordinateSystem;
            Content = graphics;
        }
        
        #region Specific Modelica members

        ///<summary>
        ///</summary>
        [Mapping("coordinateSystem")]
        public CoordinateSystem coordinateSystem { get; set; }

        ///<summary>
        ///</summary>
        [Mapping("graphics"), DefaultMapping]
        public ObservableCollection<IGraphicsItem> Content { get; set; }

        public override bool IsDefault {
            get {
                return coordinateSystem.IsDefault &&
                       Content.Count == 0;
            }
        }

        #endregion
    }
}